package com.xindong.paking.controller;

import com.xindong.paking.service.FileUploadService;
import com.xindong.paking.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author jielun
 * @Date 2023/1/10 14:49
 * @Version 1.0
 */
@Api(tags = "文件上传")
@RestController
@RequestMapping("/paking/file")
public class FileUploadController {

    @Autowired
    private FileUploadService service;

    @PostMapping("upload")
    @ApiOperation(value = "文件上传")
    public Result upload(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestParam("file") MultipartFile file) {
        String uploadUrl = service.upload(file);
        return Result.success("上传成功",uploadUrl);
    }
}
